


import java.rmi.RemoteException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.net.MalformedURLException; 

public class CalculPiClient {

	final static int N = 20;
	final static int n = 20*10000;

	public static void main (String[] args){
		CalculPiInterface[] lol = new CalculPiInterface[N];
		try{
			for(int k = 0; k < N; k++){
				lol[k] = (CalculPiInterface) Naming.lookup("//moselle.polytechnique.fr:1142/CalculPi" + k);
			}
		}
		catch (NotBoundException e){
			System.out.println ("\"//marne.polytechnique.fr/Hello\" does not exist");
		} catch (MalformedURLException e) {
			System.out.println ("\"//marne.polytechnique.fr/Hello\" not a valid URL ");
		} catch (RemoteException e) {
			System.out.println ("Some remote exception in lookup"+e);
		}
		try {
			float resultat = (float) 0;
			float coucou = (float) 0;

			for(int k = 0; k < N; k++){
				coucou = lol[k].calcul();
				System.out.println("le serveur "+ k + " a calcule : " + coucou);
				resultat = resultat + coucou;
			}
			System.out.println("La somme totale est :");
			for(int i = 0; i < 6; i++){
				System.out.println("*");
			}
			System.out.println("TADAMMMMMMMM!!!!");
			System.out.println(resultat + " !!!!");
			
		} catch (RemoteException e) { 
			System.out.println ("Some remote exception for hello.say()"+e);
		}
	}
}
